<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
                <label class="el-form-item-label">ID</label>
                <el-input v-model="query.id" clearable placeholder="ID" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">产品SN</label>
                <el-input v-model="query.productSn" clearable placeholder="产品SN" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">产品型号</label>
                <el-input v-model="query.productCode" clearable placeholder="产品型号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">产品类型</label>
                <el-input v-model="query.productType" clearable placeholder="产品类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">订单编号</label>
                <el-input v-model="query.orderCode" clearable placeholder="订单编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">工单编号</label>
                <el-input v-model="query.workOrderCode" clearable placeholder="工单编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">产线编号</label>
                <el-input v-model="query.lienCode" clearable placeholder="产线编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">工段编号</label>
                <el-input v-model="query.sectionCode" clearable placeholder="工段编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">工位编号</label>
                <el-input v-model="query.stationCode" clearable placeholder="工位编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">工序编号</label>
                <el-input v-model="query.operationCode" clearable placeholder="工序编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">设备编号</label>
                <el-input v-model="query.deviceCode" clearable placeholder="设备编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                  <el-select v-model="query.paramResult" clearable filterable
                             placeholder="请选择" style="width: 185px;" class="filter-item" @change="crud.toQuery" >
                    <el-option
                            v-for="item in dict.result"
                            :key="item.id"
                            :label="item.label"
                            :value="item.value" />
                  </el-select>
                <label class="el-form-item-label">参数编码</label>
                <el-input v-model="query.paramCode" clearable placeholder="参数编码" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">参数名称</label>
                <el-input v-model="query.paramName" clearable placeholder="参数名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">参数值</label>
                <el-input v-model="query.paramValue" clearable placeholder="参数值" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">判断范围</label>
                <el-input v-model="query.paramRange" clearable placeholder="判断范围" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">参数单位</label>
                <el-input v-model="query.paramUnit" clearable placeholder="参数单位" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">测试顺序</label>
                <el-input v-model="query.paramNumber" clearable placeholder="测试顺序" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">过站ID</label>
                <el-input v-model="query.passStationId" clearable placeholder="过站ID" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">创建人</label>
                <el-input v-model="query.createBy" clearable placeholder="创建人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
                <label class="el-form-item-label">更新人</label>
                <el-input v-model="query.updateBy" clearable placeholder="更新人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <date-range-picker
          v-model="query.createTime"
          start-placeholder="createTimeStart"
          end-placeholder="createTimeStart"
          class="date-item"
        />
        <date-range-picker
          v-model="query.updateTime"
          start-placeholder="updateTimeStart"
          end-placeholder="updateTimeStart"
          class="date-item"
        />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="产品SN">
            <el-input v-model="form.productSn" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品型号">
            <el-input v-model="form.productCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品类型">
            <el-input v-model="form.productType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单编号">
            <el-input v-model="form.orderCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单编号">
            <el-input v-model="form.workOrderCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产线编号">
            <el-input v-model="form.lienCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工段编号">
            <el-input v-model="form.sectionCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工位编号">
            <el-input v-model="form.stationCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工序编号">
            <el-input v-model="form.operationCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="设备编号">
            <el-input v-model="form.deviceCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="判断结果">
            <el-select v-model="form.paramResult" filterable placeholder="请选择">
              <el-option
                v-for="item in dict.result"
                :key="item.id"
                :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="参数编码">
            <el-input v-model="form.paramCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="参数名称">
            <el-input v-model="form.paramName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="参数值">
            <el-input v-model="form.paramValue" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="判断范围">
            <el-input v-model="form.paramRange" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="参数单位">
            <el-input v-model="form.paramUnit" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="测试顺序">
            <el-input v-model="form.paramNumber" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建人">
            <el-input v-model="form.createBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-date-picker v-model="form.createTime" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人">
            <el-input v-model="form.updateBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-date-picker v-model="form.updateTime" type="datetime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="productSn" label="产品SN" />
        <el-table-column prop="productCode" label="产品型号" />
        <el-table-column prop="productType" label="产品类型" />
        <el-table-column prop="orderCode" label="订单编号" />
        <el-table-column prop="workOrderCode" label="工单编号" />
        <el-table-column prop="lienCode" label="产线编号" />
        <el-table-column prop="sectionCode" label="工段编号" />
        <el-table-column prop="stationCode" label="工位编号" />
        <el-table-column prop="operationCode" label="工序编号" />
        <el-table-column prop="deviceCode" label="设备编号" />
        <el-table-column prop="paramResult" label="判断结果">
          <template slot-scope="scope">
            {{ dict.label.result[scope.row.paramResult] }}
          </template>
        </el-table-column>
        <el-table-column prop="paramCode" label="参数编码" />
        <el-table-column prop="paramName" label="参数名称" />
        <el-table-column prop="paramValue" label="参数值" />
        <el-table-column prop="paramRange" label="判断范围" />
        <el-table-column prop="paramUnit" label="参数单位" />
        <el-table-column prop="paramNumber" label="测试顺序" />
        <el-table-column prop="createBy" label="创建人" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="updateBy" label="更新人" />
        <el-table-column prop="updateTime" label="更新时间" />
        <el-table-column v-if="checkPer(['admin','dataCourseParam:edit','dataCourseParam:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDataCourseParam from '@/api/data/dataCourseParam'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, productSn: null, productCode: null, productType: null, orderCode: null, workOrderCode: null, lienCode: null, sectionCode: null, stationCode: null, operationCode: null, deviceCode: null, paramResult: null, paramCode: null, paramName: null, paramValue: null, paramRange: null, paramUnit: null, paramNumber: null, passStationId: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'DataCourseParam',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['result'],
  cruds() {
    return CRUD({ title: '过程数据', url: 'api/dataCourseParam', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDataCourseParam }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'dataCourseParam:add'],
        edit: ['admin', 'dataCourseParam:edit'],
        del: ['admin', 'dataCourseParam:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'id', display_name: 'ID' },
        { key: 'productSn', display_name: '产品SN' },
        { key: 'productCode', display_name: '产品型号' },
        { key: 'productType', display_name: '产品类型' },
        { key: 'orderCode', display_name: '订单编号' },
        { key: 'workOrderCode', display_name: '工单编号' },
        { key: 'lienCode', display_name: '产线编号' },
        { key: 'sectionCode', display_name: '工段编号' },
        { key: 'stationCode', display_name: '工位编号' },
        { key: 'operationCode', display_name: '工序编号' },
        { key: 'deviceCode', display_name: '设备编号' },
        { key: 'paramResult', display_name: '判断结果' },
        { key: 'paramCode', display_name: '参数编码' },
        { key: 'paramName', display_name: '参数名称' },
        { key: 'paramValue', display_name: '参数值' },
        { key: 'paramRange', display_name: '判断范围' },
        { key: 'paramUnit', display_name: '参数单位' },
        { key: 'paramNumber', display_name: '测试顺序' },
        { key: 'passStationId', display_name: '过站ID' },
        { key: 'createBy', display_name: '创建人' },
        { key: 'updateBy', display_name: '更新人' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
